package cn.fl.mcr.transform;

import cn.fl.mcr.export.McrBillCheckDetailExportBean;
import cn.fl.mcr.export.McrBillCheckExportBean;
import cn.lionbridgecapital.loan.model.constant.McrBillMConstant;
import cn.lionbridgecapital.loan.model.dto.McrBillAfterCheckDDTO;
import cn.lionbridgecapital.loan.model.dto.McrBillCheckDetailDTO;
import cn.lionbridgecapital.loan.model.enu.McrBillCheckType;
import cn.lionbridgecapital.loan.model.vo.McrBillCheckDetailVO;

import java.util.Objects;


/**
 * @Description: 账单对账明细表 转换器
 * @Description: VO是客户端传递数据到服务端进行转换的数据 
 * @Description: VO转换数据变成DTO传递到服务端 
 * @Description: VO不能在服务端出现
 */
public class BaseMcrBillCheckDetailVOTransform {


	/**
	 * DTO 转  VO
	 * @param dto McrBillCheckDetailDTO
	 * @return McrBillCheckDetailVO
	 */
	public static McrBillCheckDetailVO baseToVO(McrBillCheckDetailDTO dto) {
		McrBillCheckDetailVO  vo = null;
		if (dto != null) { 
			vo = new McrBillCheckDetailVO();
			vo.setId(dto.getId());
			vo.setBillId(dto.getBillId());
			vo.setBatchNo(dto.getBatchNo());//文件批次号
			vo.setCstId(dto.getCstId());//客户ID
			vo.setCstNm(dto.getCstNm());//客户姓名
			vo.setCrCntNo(dto.getCrCntNo());//贷款合同号
			vo.setLoanChannel(dto.getLoanChannel());//资方类型
			vo.setLoanDate(dto.getLoanDate());//放款日期
			vo.setLoanTime(dto.getLoanTime());//放款时间
			vo.setLoanBank(dto.getLoanBank());//放款银行
			vo.setCrAmt(dto.getCrAmt());//放款金额
			vo.setLoanAccount(dto.getLoanAccount());//放款账户
			vo.setCheckStatus(dto.getCheckStatus());//处理状态：0未处理，1有差异，2无差异
			vo.setCheckRemark(dto.getCheckRemark());//差异备注
			vo.setLoanDescription(dto.getLoanDescription());//交易结果描述
			vo.setCrCntNoUniqId(dto.getCrCntNoUniqId());//贷款合同唯一编号
			vo.setSource(dto.getSource());//数据源
			vo.setCheckId(dto.getCheckId());//外键ID

			vo.setCrtTm(dto.getCrtTm());//创建时间
			vo.setCrtUsrId(dto.getCrtUsrId());//创建人
			vo.setMdfTm(dto.getMdfTm());//修改时间
			vo.setMdfUsrId(dto.getMdfUsrId());//修改人
		}
		return vo;
	}

	/**
	 * VO 转 DTO
	 * @param vo McrBillCheckDetailVO
	 * @return McrBillCheckDetailDTO
	 */
	public static McrBillCheckDetailDTO baseToDTO(McrBillCheckDetailVO vo) {
		McrBillCheckDetailDTO dto = null;
		if (vo != null) {
			dto = new McrBillCheckDetailDTO();
			dto.setId(vo.getId());
			dto.setBillId(vo.getBillId());//小贷账单ID
			dto.setBatchNo(vo.getBatchNo());//文件批次号
			dto.setCstId(vo.getCstId());//客户ID
			dto.setCstNm(vo.getCstNm());//客户姓名
			dto.setCrCntNo(vo.getCrCntNo());//贷款合同号
			dto.setLoanChannel(vo.getLoanChannel());//资方类型
			dto.setLoanDate(vo.getLoanDate());//放款日期
			dto.setLoanTime(vo.getLoanTime());//放款时间
			dto.setLoanBank(vo.getLoanBank());//放款银行
			dto.setCrAmt(vo.getCrAmt());//放款金额
			dto.setLoanAccount(vo.getLoanAccount());//放款账户
			dto.setCheckStatus(vo.getCheckStatus());//处理状态：0未处理，1有差异，2无差异
			dto.setCheckRemark(vo.getCheckRemark());//差异备注
			dto.setLoanDescription(vo.getLoanDescription());//交易结果描述
			dto.setCrCntNoUniqId(vo.getCrCntNoUniqId());//贷款合同唯一编码
			dto.setTradeStatus(vo.getTradeStatus());//交易状态
			dto.setSource(vo.getSource());//数据源
			dto.setCheckId(vo.getCheckId());//外键ID

			dto.setCrtTm(vo.getCrtTm());//创建时间
			dto.setCrtUsrId(vo.getCrtUsrId());//创建人
			dto.setMdfTm(vo.getMdfTm());//修改时间
			dto.setMdfUsrId(vo.getMdfUsrId());//修改人
		}
		return dto;
	}

	public static McrBillCheckExportBean dtoToExport(McrBillCheckDetailDTO dto) {
		if (Objects.isNull(dto)) {
			return null;
		}
		McrBillCheckExportBean exportBean = new McrBillCheckExportBean();
		exportBean.setCrCntNo(dto.getCrCntNo());
		exportBean.setCrCntNoUniqId(dto.getCrCntNoUniqId());
		exportBean.setCstNm(dto.getCstNm());
		exportBean.setCheckRemark(dto.getCheckRemark());
		exportBean.setCrAmt(dto.getCrAmt().toString());
		exportBean.setLoanAccount(dto.getLoanAccount());
		exportBean.setLoanDate(dto.getLoanDate());
		exportBean.setLoanChannel(McrBillMConstant.LOAN_CHANNEL_DESC_MAP.get(dto.getLoanChannel()));
		return exportBean;
	}


	public static McrBillCheckDetailExportBean checkDetailToExport(McrBillAfterCheckDDTO dto) {
		if (Objects.isNull(dto)) {
			return null;
		}
		McrBillCheckDetailExportBean exportBean = new McrBillCheckDetailExportBean();
		exportBean.setLoanChannel(McrBillMConstant.LOAN_CHANNEL_DESC_MAP.get(dto.getLoanChannel()));
		exportBean.setCrCntNo(dto.getCrCntNo());
		exportBean.setCstNm(dto.getCstNm());
		exportBean.setState(McrBillCheckType.getCheckStatusDesc(dto.getState()).getValue());
		exportBean.setCrAmt(dto.getAmtPrincipal());
		exportBean.setCrAmtIns(dto.getAmtInterest());
		exportBean.setCrAmtOvd(dto.getAmtOverdue());
		exportBean.setCrAmtBank(dto.getAmtPrincipalBank());
		exportBean.setCrAmtInsBank(dto.getAmtInterestBank());
		exportBean.setCrAmtOvdBank(dto.getAmtOverdueBank());
		exportBean.setAmtAssuerBank(dto.getAmtAssuerBank());
		exportBean.setAmtPenalBank(dto.getAmtPenalBank());
		exportBean.setAmtAssuer(dto.getAmtAssuer());
		exportBean.setAmtPenal(dto.getAmtPenal());
		return exportBean;
	}
}
